<template>
  <!-- 左侧tab -->
  <div
    class="column-tab-box"
    :style="{ backgroundColor: propsData.params.leftTabBg }"
  >
    <section class="tabs-section">
      <div
        class="tab-item"
        v-for="(item, index) in classifyList"
        :key="index"
        @click="handleTab(item, index)"
        :class="[
          active == index ? 'activeTab' : '',
          active == index - 1 ? 'activeTabTop' : '',
          active == index + 1 ? 'activeTabDown' : '',
        ]"
        :style="{ backgroundColor: propsData.params.leftTabBg }"
      >
        <div
          v-if="active == index"
          :style="{ background: propsData.params.activeLineColor }"
          class="active-line"
        ></div>
        <div class="tab-content">
          <span :style="fontCss(index)">{{ item.title }}</span>
          <div class="item-hover">
            <div
              class="edit-box"
              @click.stop="
                handleClassifyTabItem(
                  'classifyDefaultActiveControl',
                  item,
                  index
                )
              "
            >
              <i class="iconfont icon-mokuai-bianji"></i>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
import defaultTab from "./defaultTab.vue";
import subtitleTab from "./subtitleTab.vue";
import { mixinsModuleCss } from "@/components/DiyNew/diy/mixins/index.js";

export default {
  name: "",
  props: {
    propsData: {
      type: Object,
      default: {},
    },
    active: {
      type: Number,
      default: 0,
    },
  },
  mixins: [mixinsModuleCss],
  data() {
    return {};
  },
  components: {
    defaultTab,
    subtitleTab,
  },
  mounted() {
    console.log("垂直的！！！", this.propsData);
  },
  watch: {},
  computed: {
    styleType() {
      return this.propsData.params.styleType || "1";
    },
    tabStyle() {
      return this.propsData.params.tabStyle || "1";
    },
    classifyList() {
      if (this.propsData.params.classifyList.length <= 0) {
        let arr = [];
        for (let i = 0; i < 6; i++) {
          let obj = {
            title: "标题",
            subTitle: "副标题",
            link: null,
            data: null,
            dataFrom: "",
            classifyId: "",
          };
          arr.push(obj);
        }
        return arr;
      }

      return this.propsData.params.classifyList;
    },
  },
  methods: {
    // 点击切换tab
    handleTab(item, index) {
      this.$emit("changeTab", { item, index });
    },
    // 点击编辑当前状态
    verticalTabItemEdit(e) {
      this.$emit("handleClassifyTabItem", e);
    },
    // 点击编辑当前状态
    handleClassifyTabItem(name, item, index) {
      this.handleTab(item, index);
      console.log("点击单个专题导航");
      let data = Object.assign({}, this.propsData);
      data.controlComName = name;
      this.$emit("handleClassifyTabItem", data);
    },
    fontCss(index) {
      let style = Object.assign({}, this.propsData.params.defaultTab.fontCss);
      style.fontSize = style.fontNum + "px";
      style.color = this.propsData.params.subtitleTab.defaultTitleColor;
      if (index == this.active) {
        style.color = this.propsData.params.defaultTab.activeColor;
      }
      return style;
    },
  },
};
</script>

<style lang="scss" scoped>
.column-tab-box {
  width: 80px;
  height: 100%;
  background-color: #ffffff;
  position: relative;
  top: -1px;

  .tabs-section {
    display: flex;
    flex-direction: column;
    background-color: #f2f2f2;
  }
  .tab-item {
    width: 100%;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background-color: #ffffff;
    .tab-content {
      width: 70%;
      word-break: break-all;
      font-size: 13px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #6b6b6b;
      position: relative;
      z-index: 5;
      .item-hover {
        width: 102%;
        height: 100%;
        border: 1px solid #1890fc;
        position: absolute;
        left: 0;
        top: 0;
        display: none;
        z-index: 1;
        .edit-box {
          width: 20px;
          height: 20px;
          background: #1890fc;
          border-radius: 0px 0px 0px 4px;
          display: flex;
          justify-content: center;
          align-items: center;
          cursor: pointer;
          position: absolute;
          right: 0;
          top: 0;
          .iconfont {
            font-size: 18px;
            color: #ffffff;
          }
        }
      }
    }
    .tab-content:hover > .item-hover {
      display: block;
    }
    .active-line {
      width: 3px;
      height: 20px;
      background: #fa2c1b;
      position: absolute;
      left: 0;
      top: 12.5px;
      z-index: 1;
    }
  }
  .activeTab {
    background-color: #f2f2f2 !important;
    .tab-content {
      span {
        font-weight: 600;
        color: #000000;
      }
    }
  }
  .activeTabTop {
    border-radius: 0 8px 0 0;
    overflow: hidden;
  }
  .activeTabDown {
    border-radius: 0 0 8px 0;
    overflow: hidden;
  }
}
</style>
